package com.yxw.live_vod_boot.controller;

import com.yxw.live_vod_facade.dto.VideoCoinQueryDTO;
import com.yxw.live_vod_boot.dto.YxLiveCostAddDTO;
import com.yxw.live_vod_boot.dto.YxVideoCoinQueryDTO;
import com.yxw.live_vod_boot.service.VideoCoinService;
import com.yxw.live_vod_boot.vo.YxVideoCoinVO;
import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.common.helper.ResultHelper;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 视频币明细
 * @author xiexuxin
 * @date 2023-11-17
 */
@RestController
@Api(value = "视频币明细", tags = "视频币明细")
@Slf4j
@Validated
@RequestMapping("/api/video_coin")
public class VideoCoinController {

    @Autowired
    private VideoCoinService videoCoinService;

    @ApiOperation(value = "根据id查询视频币明细详情数据")
    @PostMapping(value = "/get_video_coin_by_id")
    public BaseResult getVideoCoinById(@RequestParam("videoCoinId") Long videoCoinId) {
        YxVideoCoinVO vo = videoCoinService.getVideoCoinById(videoCoinId);
        return BaseResult.doSuccess(vo,"查询成功");
    }

    @ApiOperation(value = "视频币明细列表查询")
    @PostMapping(value = "/get_video_coin_list")
    public BaseResult<PageVO<List<YxVideoCoinVO>>> getVideoCoinList(@RequestBody YxVideoCoinQueryDTO dto) {
        PageVO<List<YxVideoCoinVO>> pageVO = videoCoinService.getVideoCoinList(dto);
        return ResultHelper.fillWithSuccess(pageVO);
    }

    @ApiOperation(value = "视频币明细列表查询后台")
    @PostMapping(value = "/get_video_coin_list_backend")
    public BaseResult<PageVO<YxVideoCoinVO>> getVideoCoinListBackend(@RequestBody VideoCoinQueryDTO dto) {
        PageVO<YxVideoCoinVO> pageVO = videoCoinService.getVideoCoinListBackend(dto);
        return ResultHelper.fillWithSuccess(pageVO);
    }

    @ApiOperation(value = "新增直播支出视频币数据")
    @PostMapping(value = "/add_live_cost")
    public BaseResult addLiveCost(@RequestBody YxLiveCostAddDTO dto) {
        if (dto.getLiveId() != null && dto.getPunishId() != null){
            videoCoinService.addIllegalCostDuringLive(dto);
        }else {
            videoCoinService.addLiveCost(dto);
        }
        return BaseResult.success();
    }

}
